package com.yiqi.lottery.feature.lottery.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.entity.bo.PageData;
import com.yiqi.lottery.entity.bo.CouprceBo;
import com.yiqi.lottery.entity.bo.HallBo;
import com.yiqi.lottery.entity.bo.PayBo;
import com.yiqi.lottery.feature.lottery.contract.HallContract;
import com.yiqi.lottery.feature.lottery.contract.HomeContract;
import com.yiqi.lottery.feature.lottery.dependencies.hall.DaggerHallModelComponent;
import com.yiqi.lottery.feature.lottery.dependencies.home.DaggerHomeModelComponent;
import com.yiqi.lottery.framework.api.ApiLib;
import com.yiqi.lottery.framework.api.LotteryApi;

import java.util.HashMap;

import io.reactivex.CompletableObserver;
import io.reactivex.Observable;

import javax.inject.Inject;

public class HallModel implements HallContract.Model {

    @Inject
    LotteryApi api;

    @Inject
    public HallModel() {

        DaggerHallModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<PageData<CouprceBo>> getHallList(int page,int sort, Integer bet_type) {
        return api.getHallList(page, sort,bet_type).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<CouprceBo> getHallDetail(String id) {
        return api.getHallDetail(id).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> createCopurch(HashMap<String, Object> couprceBo) {
        return api.createCopurch(couprceBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> copurchSubmit(CouprceBo couprceBo) {
        return api.copurchSubmit(couprceBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> copurchToPay(PayBo payBo) {
        return api.copurcePay(payBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> cancleCopurch(String id) {
        return api.copurcePay(id).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}
